package com.business.business.web.web;

import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.extension.api.R;
import com.business.business.common.base.BaseController;
import com.business.business.support.annotaion.Action;
import com.business.business.support.model.RespEntity;
import com.business.business.web.service.EmgMaterialsService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Author xulumin
 * @Date 2024/3/19 11:15
 * @Version 1.0
 * @Desc 应急物资控制器
 */
@Controller
@Action
@RequestMapping(value = "emergencyMaterials")
public class EmgMaterialsController extends BaseController {

    @Resource
    private EmgMaterialsService emgMaterialsService;


    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 物资新增或者更新
     */
    @PostMapping("addOrUpdateMaterials")
    public RespEntity addOrUpdateMaterials(@RequestBody(required = false) JSONObject jsonObject) throws IllegalAccessException, InstantiationException {
        return emgMaterialsService.addOrUpdateMaterials(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 获取物资信息列表
     */
    @GetMapping("getMaterialsList")
    public RespEntity getMaterialsList(@RequestBody(required = false) JSONObject jsonObject) {
        return emgMaterialsService.getMaterialsList(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/20
     * Description: 获取物资信息
     */
    @GetMapping("getMaterialsInfo")
    public RespEntity getMaterialsInfo(@RequestBody(required = false) JSONObject jsonObject) {
        return emgMaterialsService.getMaterialsInfo(jsonObject);
    }

    /**
     * Author: xulumin
     * Date: 2024/3/19
     * Description: 删除物资信息
     */
    @PostMapping("delMaterials")
    public RespEntity delMaterials(@RequestBody(required = false) JSONObject jsonObject) {
        return emgMaterialsService.delMaterials(jsonObject);
    }

}
